home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / gui / ClassFree_src.lha / ClassFree_src / CFfuelgiclass / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-27  |  2.3 KB  |  106 lines

  1. /* Small test proggy for my listviewclass */
  2.  
  3. #include <clib/alib_protos.h>
  4. #include <proto/exec.h>
  5. #include <proto/graphics.h>
  6. #include <proto/intuition.h>
  7. #include <proto/dos.h>
  8. #include <intuition/intuition.h>
  9. #include <intuition/gadgetclass.h>
  10. #include <intuition/imageclass.h>
  11. #include <stdio.h>
  12. #include "CFbutton.h"
  13. #include "CFfuelgi.h"
  14.  
  15. #define QUIT_G   0
  16. #define NUM_GADS 1
  17.  
  18.  
  19. struct Library *CFBbase;
  20. struct Library *CFfgbase;
  21.  
  22. void main(void)
  23. {
  24.   struct Window *win;
  25.   struct Gadget *glist, *tgad, *gads[NUM_GADS];
  26.   struct Image *img;
  27.   struct IntuiMessage *imsg;
  28.   BOOL breakflag = FALSE;
  29.   LONG pos,iclass;
  30.  
  31.   CFBbase = OpenLibrary("Gadgets/CFbutton.gadget",NULL);
  32.   CFfgbase = OpenLibrary("CFfuelg.image",NULL);
  33.  
  34. //  if(lvbase) printf("Class opened\n");
  35.  
  36.   win = OpenWindowTags(NULL,
  37.           WA_Left, 200,
  38.           WA_Width,400,WA_Height,200,
  39.           WA_IDCMP, IDCMP_GADGETUP,
  40.           TAG_DONE);
  41.   SetAPen(win->RPort,1);
  42.  
  43.  
  44.   img = (struct Image *)NewObject(NULL,CFfuelgiClassName,
  45.           IA_Left, 30, IA_Top, 30,
  46.           IA_Width, 100, IA_Height, 10,
  47.           CFFG_Max,  300,
  48.           CFFG_Label, "Loading",
  49.           TAG_DONE);
  50.  
  51.  
  52.   gads[QUIT_G] = (struct Gadget *)NewObject(NULL,CFbuttonClassName,
  53.           GA_Left, 200, GA_Top, 90,
  54.           GA_Width, 50, GA_Height, 20,
  55.           GA_Text, "Quit",
  56.           GA_RelVerify, TRUE,
  57.           GA_ID, QUIT_G,
  58.           TAG_DONE);
  59.  
  60.   glist = gads[0];
  61.  
  62.   AddGList(win,glist,-1,-1,NULL);
  63.   RefreshGadgets(glist,win,NULL);
  64.  
  65.   pos = 0;
  66.   while(pos<300)
  67.   {
  68.     DrawImageState(win->RPort,img,0,0,pos,NULL);
  69.     Delay(5);
  70.     pos += 40;
  71.   }
  72.   DrawImageState(win->RPort,img,0,0,300,NULL);
  73.   Delay(5);
  74.   DrawImageState(win->RPort,img,0,0,200,NULL);
  75.   Delay(5);
  76.   DrawImageState(win->RPort,img,0,0,100,NULL);
  77.   Delay(5);
  78.   DrawImageState(win->RPort,img,0,0,0,NULL);
  79.  
  80.   while(!breakflag)
  81.   {
  82.     WaitPort(win->UserPort);
  83.     while(imsg = (struct IntuiMessage *)GetMsg(win->UserPort))
  84.     {
  85.       iclass = imsg->Class;
  86.       tgad = (struct Gadget *)imsg->IAddress;
  87.       pos = imsg->Code;
  88.       ReplyMsg((struct Message *)imsg);
  89.       if(iclass == IDCMP_GADGETUP)
  90.       {
  91.         switch(tgad->GadgetID)
  92.         {
  93.           case QUIT_G: breakflag = TRUE; break;
  94.         }
  95.       }
  96.     }
  97.   }
  98.  
  99.   RemoveGList(win,glist,-1);
  100.   pos = 0;
  101.   while(pos<NUM_GADS) DisposeObject(gads[pos++]);
  102.   DisposeObject(img);
  103.   CloseWindow(win);
  104.   CloseLibrary(CFBbase);
  105.   CloseLibrary(CFfgbase);
  106. }